<template>
  <div>
    <!-- 头部组件 -->
    <Topnav titleTxt="我的收藏"></Topnav>

    <IndexPost :post="post" v-for="(post,index) in posts" :key="index"></IndexPost>
  </div>
</template>
<script>
// 引入头部组件
import Topnav from "@/components/TopNav.vue";
import IndexPost from "@/components/IndexPost.vue";

export default {
  components: {
    Topnav,
    IndexPost
  },
  data() {
    return {
      posts: []
    };
  },
  mounted() {
    this.getCollectPosts();
  },
  methods: {
    getCollectPosts() {
      this.$axios({
        url: "/user_star",
        method: "get"
      }).then(res => {
        console.log("我的收藏页面", res);
        const { data } = res.data;
        this.posts = data;
      });
    }
  }
};
</script>